package com.channel.temperature.collect.ui.activity;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemLongClickListener;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.formatter.ValueFormatter;
import com.github.mikephil.charting.listener.ChartTouchListener;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.hjy.bluetooth.HBluetooth;
import com.hjy.bluetooth.exception.BluetoothException;
import com.hjy.bluetooth.inter.BleMtuChangedCallback;
import com.kongzue.dialogx.dialogs.BottomMenu;
import com.kongzue.dialogx.dialogs.MessageDialog;
import com.kongzue.dialogx.dialogs.PopTip;
import com.kongzue.dialogx.dialogs.WaitDialog;
import com.kongzue.dialogx.interfaces.OnBackPressedListener;
import com.kongzue.dialogx.interfaces.OnDialogButtonClickListener;
import com.kongzue.dialogx.interfaces.OnMenuItemClickListener;
import com.channel.temperature.collect.data.response.SystemInfoBean;
import com.channel.temperature.collect.ui.adapter.TaskAdapter;

import java.util.ArrayList;

public class TestThreeActivity extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        HBluetooth.BleConfig bleConfig = new HBluetooth.BleConfig();
        bleConfig.withServiceUUID("0000fe61-0000-1000-8000-00805f9b34fb")
                .withWriteCharacteristicUUID("0000fe61-0000-1000-8000-00805f9b34fb")
                .withNotifyCharacteristicUUID("0000fe61-0000-1000-8000-00805f9b34fb")
                //.liveUpdateScannedDeviceName(true)
                //命令长度大于20个字节时是否分包发送，默认false,分包时可以调两参方法设置包之间发送间隔
                //默认false,注释部分为默认值
                //.splitPacketToSendWhenCmdLenBeyond(false)
                //.useCharacteristicDescriptor(false)
                //连接后开启通知的延迟时间，单位ms，默认200ms
                //.notifyDelay(200)
                .setMtu(200, new BleMtuChangedCallback() {
                    @Override
                    public void onSetMTUFailure(int realMtuSize, BluetoothException bleException) {
                        Log.i("HBluetooth", "bleException:" + bleException.getMessage() + "  realMtuSize:" + realMtuSize);
                    }

                    @Override
                    public void onMtuChanged(int mtuSize) {
                        Log.i("HBluetooth", "Mtu set success,mtuSize:" + mtuSize);
                    }
                });

        BottomMenu.show(new String[]{"新标签页中打开", "稍后阅读", "复制链接网址"})
                .setMessage("这里是标题")
                .setOnMenuItemClickListener(new OnMenuItemClickListener<BottomMenu>() {
                    @Override
                    public boolean onClick(BottomMenu dialog, CharSequence text, int index) {
                        return false;
                    }
                });

        boolean isOn = true;
        String result = isOn ? "开锁" : "闭锁";
        TaskAdapter adapter = new TaskAdapter();
        adapter.setOnItemLongClickListener(new OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                return false;
            }
        });
        MessageDialog messageDialog = new MessageDialog("多选对话框", "移除App会将它从主屏幕移除并保留其所有数据。", "删除App", "取消", "移至App资源库")
                .setButtonOrientation(LinearLayout.VERTICAL);
        messageDialog.setOtherButtonClickListener(new OnDialogButtonClickListener<MessageDialog>() {
            @Override
            public boolean onClick(MessageDialog dialog, View v) {

                return false;
            }
        });
        messageDialog.setOnBackPressedListener(new OnBackPressedListener<MessageDialog>() {
            @Override
            public boolean onBackPressed(MessageDialog dialog) {
                return false;
            }
        });
        messageDialog.show();

        WaitDialog.show("Please Wait!")
                .setOnBackPressedListener(new OnBackPressedListener<WaitDialog>() {
                    @Override
                    public boolean onBackPressed(WaitDialog dialog) {
                        PopTip.show("按下返回");
                        return false;
                    }
                });
        new Gson().fromJson("sasasas", new TypeToken<ArrayList<SystemInfoBean>>() {
        }.getType());

        LineChart lineChart = null;
        lineChart.getXAxis().setValueFormatter(new ValueFormatter() {
            @Override
            public String getFormattedValue(float value) {
                return "";
            }
        });
        lineChart.setOnTouchListener(new ChartTouchListener(lineChart) {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return false;
            }
        });
        lineChart.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return false;
            }
        });
         byte[] key = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};


    }
}